import java.util.Date;
import java.util.List;

import org.flynenu.ums.common.entity.City;
import org.flynenu.ums.common.entity.core.DataSourceFactory;
import org.hibernate.Session;



public class HibernateTest01 {
	public static void main(String[] args){
		Session session  = DataSourceFactory.getSession().buildeSession();
		City city1 = new City();
		city1.setName("bbbbb");
		city1.setProvinceId(1);
		city1.setCreateDate(new Date());
		city1.setId(11);
		session.beginTransaction();
		session.save(city1);
		
		List<City> list = session.createSQLQuery("select * from city").addEntity(City.class).list();
		
			System.out.println("size:" + list.size());
			
		for(City city: list){
			System.out.println(city.getId() + "|" + city.getName());
		}
		
		session.getTransaction().commit();
		session.flush();
		session.close();
	}
}
